#include "CouncilMember.h"

#include "Helpers.h"

CouncilMember& CouncilMember::operator=( const CouncilMember& other )
{
  if (this == &other)
    return *this;
  m_id = other.m_id;
  m_name = other.m_name;
  m_address = other.m_address;
  m_phone = other.m_phone;
  return *this;
}

bool CouncilMember::operator==( const CouncilMember& other ) const
{
  return m_id == other.m_id && m_name == other.m_name &&
    m_address == other.m_address && m_phone == other.m_phone;
}

bool CouncilMember::operator<(const CouncilMember& other) const
{
  return as<int>(m_id) < as<int>(other.id());
}

std::ostream& operator<<( std::ostream& stream, const CouncilMember &member )
{
  return stream << 
    member.id() << c_delm <<
    member.name() << c_delm <<
    member.address() << c_delm <<
    member.phone() << std::endl;
}

std::istream& operator>>( std::istream& stream, CouncilMember& member )
{
  CsvRow row;
  stream >> row;
  if (row.empty())
    return stream;
  member = CouncilMember(row[0], row[1], row[2], row[3]);
  return stream;
}
